import 'package:flutter/widgets.dart';

class UnspecifiedLexicalItemObscureCardTranslation {
  static final delegate = _UnspecifiedLexicalItemObscureCardTranslationDelegate();

  static UnspecifiedLexicalItemObscureCardTranslation of(BuildContext context) {
    return Localizations.of(context, UnspecifiedLexicalItemObscureCardTranslation);
  }

  late String _languageCode;

  Future<void> load(Locale locale) async {
    _languageCode = locale.languageCode;
  }

  String _resolve(Map<String, String> translations) {
    return translations[_languageCode]!;
  }

  String get exposureButtonTitle {
    return _resolve(const {
      'ru': 'показать',
      'en': 'show',
    });
  }
}

class _UnspecifiedLexicalItemObscureCardTranslationDelegate
    extends LocalizationsDelegate<UnspecifiedLexicalItemObscureCardTranslation> {
  @override
  bool isSupported(Locale locale) => const ['ru', 'en'].contains(locale.languageCode);

  @override
  bool shouldReload(LocalizationsDelegate<UnspecifiedLexicalItemObscureCardTranslation> old) =>
      false;

  @override
  Future<UnspecifiedLexicalItemObscureCardTranslation> load(Locale locale) async {
    final translation = UnspecifiedLexicalItemObscureCardTranslation();
    await translation.load(locale);
    return translation;
  }
}
